//
//  CorP5eCustomFilter.m
//  CorP5e
//
//  Created by Matthew Giant on 9/29/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "CorP5eCustomFilter.h"


@implementation CorP5eCustomFilter

- (id)initWithCode:(NSString *)code
{
	if ( self = [super init] )
	{
		CustomFilter *custom = [[CustomFilter alloc] initWithCode:code];
	}
	
	return self;
}

- (void)setFilterValueWithKey:(NSString *)keyName 
					withImage:(CIImage *)value
{
}

- (void)setFilterValueWithKey:(NSString *)keyName
				    withFloat:(float)value
{
}

- (void)setFilterValueWithKey:(NSString *)keyName
				   withVector:(CIVector *)value
{
}

@end


@implementation CustomFilter

@synthesize inputImage;

- (id)initWithCode:(NSString *)kernelCode
{
	if ( self = [super init] )
	{
		NSArray *kernels = [CIKernel kernelsWithString:kernelCode];
		
		if ( kernels && [kernels count] > 0 )
		{
			kernel = [[kernels objectAtIndex:0] retain];
		}
	}
	
	return self;
}

- (CIImage *)outputImage
{
	CISampler *src = [CISampler samplerWithImage: inputImage];
	return [self apply: kernel, src, nil];
}

@end